package com.qbw.app.module.common.util;

import android.text.TextUtils;

import com.lib.util.DeviceUtil;
import com.qbw.app.Constant;
import com.qbw.app.XApplication;
import com.qbw.l.L;
import com.qbw.log.XLog;

import java.util.Locale;

/**
 * @author qinbaowei
 * @date 2018/1/27
 * @email qbaowei@qq.com
 */

public class CountryUtil {

    public static final int COUNTRY_ID_CHINA = 45;
    public static final int COUNTRY_ID_MALAI = 126;

    public static int getCountryId() {
        int cid = 0;
        String imsi = DeviceUtil.getIMSI(XApplication.getInstance());
        /*if (imsi.startsWith("46000") || imsi.startsWith("46002"))
        {//因为移动网络编号46000下的IMSI已经用完，所以虚拟了一个46002编号，134/159号段使用了此编号
            //中国移动
            cid = 45;
        } else if (imsi.startsWith("46001")) {
            //中国联通
            cid = 45;
        } else if (imsi.startsWith("46003")) {
            //中国电信
            cid = 45;
        }*/
        if (!TextUtils.isEmpty(imsi)) {
            if (imsi.startsWith("460")) {//中国
                cid = COUNTRY_ID_CHINA;
            } else if (imsi.startsWith("502")) {//马来
                cid = COUNTRY_ID_MALAI;
            }
        }
        return cid;
    }


    public static int getLanguageId() {
        String lang = Locale.getDefault().getLanguage();
        L.GL.i("current language:%s", lang);
        return "zh".equals(lang) ? Constant.LANGUAGE_ID_CHINESE : Constant.LANGUAGE_ID_ENGLISH;
    }

}
